﻿using System;
using System.Text;

namespace CalcWageHours
{
    class Program
    {
        static void Main(string[] args)
        {
            double regHours = 0;
            double otHours = 0;
            double rate = 0;
            double weeklyPay = 0;
            bool Valid;
            int employee = 0;
            string name;

            do
                {
                    Valid = true;
                    try
                    {
                        Console.Write ("\n\nHow many Employees would you like to enter? :  ");
                        employee = Convert.ToInt32(Console.ReadLine());
                        Console.WriteLine();
                    }
                    catch (FormatException NotNum)
                    {
                        NotNum = new FormatException("Please enter a Name.");
                        Console.WriteLine("ERROR! {0}", NotNum);
                        Valid = false;
                    }
                } while (!Valid);

            while (employee > 0)
            {
                Console.Write ("Please enter the name of the employee:  ");
                name = Console.ReadLine();
                Console.Write("Current employee is {0}\n\n", name);
                
                do
                {
                    Valid = true;
                    try
                    {
                        Console.Write ("Enter the total hours {0} worked:  ", name);
                        regHours = Convert.ToDouble(Console.ReadLine());
                    }
                    catch (FormatException NotNum)
                    {
                        NotNum = new FormatException("Please enter a numberic value!!");
                        Console.WriteLine("ERROR! {0}", NotNum);
                        Valid = false;
                    }
                } while (!Valid);

                do
                {
                    Valid = true;
                    try
                    {
                        Console.Write ("Enter total overtime Hours {0} worked:  ", name);
                        otHours = Convert.ToDouble(Console.ReadLine());
                    }
                    catch (FormatException NotNum)
                    {
                        NotNum = new FormatException("Please enter a numberic value!!");
                        Console.WriteLine("ERROR! {0}", NotNum);
                        Valid = false;
                    }
                } while (!Valid);

                do
                {
                    Valid = true;
                    try
                    {
                        Console.Write ("Enter {0}'s pay rate:  ", name);
                        rate = Convert.ToDouble(Console.ReadLine());
                        Console.WriteLine();
                    }
                    catch (FormatException NotNum)
                    {
                        NotNum = new FormatException("Please enter a numberic value.");
                        Console.WriteLine("ERROR! {0}", NotNum);
                        Valid = false;
                    }
                } while (!Valid);


                weeklyPay = rate * (regHours + (otHours * 1.5));

                Console.WriteLine("The total weekly amount paid {0} is : ${1:N2}\n\n", name, weeklyPay);
                employee--;

                if (employee >= 2)
                {
                    Console.WriteLine("There are {0} Employees left to enter.\n", employee);
                }
                else if (employee == 1)
                {
                    Console.WriteLine("There is only one (1) employee left to enter.\n");
                }
                else if (employee == 0) {}
            }

            Console.WriteLine("There is no more data required to be entered for the amount of Employees you wanted to Ask about, Goodbye.");
            Console.ReadKey(true);
        }
    }
}
